home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / checkbox / plugins / lock_prompt.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-10-12  |  1.6 KB  |  34 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import posixpath
  5. from gettext import gettext as _
  6. from checkbox.contrib.glock import GlobalLock, LockAlreadyAcquired
  7. from checkbox.lib.safe import safe_make_directory
  8. from checkbox.properties import Path
  9. from checkbox.plugin import Plugin
  10.  
  11. class LockPrompt(Plugin):
  12.     filename = Path(default = '%(checkbox_data)s/lock')
  13.     
  14.     def register(self, manager):
  15.         super(LockPrompt, self).register(manager)
  16.         self._lock = None
  17.         self._manager.reactor.call_on('prompt-begin', self.prompt_begin)
  18.  
  19.     
  20.     def prompt_begin(self, interface):
  21.         directory = posixpath.dirname(self.filename)
  22.         safe_make_directory(directory)
  23.         self._lock = GlobalLock(self.filename)
  24.         
  25.         try:
  26.             self._lock.acquire()
  27.         except LockAlreadyAcquired:
  28.             self._manager.reactor.fire('prompt-error', interface, _('Another checkbox is running'), _('There is another checkbox running. Please close it first.'))
  29.             self._manager.reactor.stop_all()
  30.  
  31.  
  32.  
  33. factory = LockPrompt
  34.